(function(){"use strict";BX.namespace("BX.Landing.UI.Panel");BX.Landing.UI.Panel.DetailPage=function(n,e){BX.Landing.UI.Panel.URLList.apply(this,arguments);this.layout.classList.add("landing-ui-panel-detail-page");this.overlay.classList.add("landing-ui-panel-detail-page");this.cache=new BX.Cache.MemoryCache;document.body.appendChild(this.layout)};BX.Landing.UI.Panel.DetailPage.instance=null;BX.Landing.UI.Panel.DetailPage.getInstance=function(){if(!BX.Landing.UI.Panel.DetailPage.instance){BX.Landing.UI.Panel.DetailPage.instance=new BX.Landing.UI.Panel.DetailPage("detail_page_panel",{title:BX.Landing.Loc.getMessage("LANDING_BLOCK__DETAIL_PAGE_PANEL_TITLE")})}return BX.Landing.UI.Panel.DetailPage.instance};BX.Landing.UI.Panel.DetailPage.prototype={constructor:BX.Landing.UI.Panel.DetailPage,__proto__:BX.Landing.UI.Panel.URLList.prototype,getSources:function(){return this.cache.remember("sources",function(){var n=BX.Landing.PageObject.getRootWindow();return n.BX.Landing.Main.getInstance().options.sources})},onSourceClick:function(n){this.sidebarButtons.forEach(function(e){if(e.id===n.id){e.activate();return}e.deactivate()});this.content.innerHTML="";this.showLoader();this.content.appendChild(BX.create("div",{props:{className:"ui-alert ui-alert-warning landing-ui-panel-list-description"},children:[BX.create("span",{props:{className:"ui-alert-message"},html:BX.Landing.Loc.getMessage("LANDING_BLOCK__DETAIL_PAGE_LIST_DESCRIPTION")})]}));BX.Landing.Backend.getInstance().getDynamicTemplates(n.id).then(function(n){n.forEach(function(n){this.appendCard(this.createTemplatePreview(n))},this);this.loader.hide()}.bind(this))},createTemplatePreview:function(n){return new BX.Landing.UI.Card.LandingPreviewCard({title:n.TITLE,description:n.DESCRIPTION,preview:n.PREVIEW2X,onClick:this.onTemplateClick.bind(this,n)})},onTemplateClick:function(n){this.loader.show();var e=BX.Landing.Backend.getInstance();e.action("Utils::checkMultiFeature",{code:["create_page","publication_page"]}).then(function(t){if(!t||t==="false"){var i=BX.Landing.PageObject.getRootWindow();i.BX.Landing.PaymentAlertShow({message:BX.Landing.Loc.getMessage("LANDING_PUBLIC_PAGE_REACHED")});this.loader.hide()}else{e.action("Landing::addByTemplate",{siteId:e.getSiteId(),code:n.ID,fields:{ID:e.getLandingId()}}).then(function(e){this.loader.hide();this.onChange({type:"landing",id:e,name:n.TITLE});var t=this.sidebarButtons.getActive();if(t){var i=t.id;var a=BX.Landing.Env.getInstance();var s=a.getOptions();var o=s.sources.find(function(n){return n.id===i});if(o){o.default.detail="#landing"+e}a.setOptions(s)}}.bind(this))}}.bind(this))},showSourcesButtons:function(){this.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton("templates",{text:BX.Landing.Loc.getMessage("LANDING_BLOCK__DETAIL_PAGE_PANEL_TEMPLATES")}));this.getSources().forEach(function(n){if(n.settings.detailPage){this.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton(n.id,{text:n.name,child:true,onClick:this.onSourceClick.bind(this,n)}))}},this)},showSitesButtons:function(){this.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton("my_sites",{text:BX.Landing.Loc.getMessage("LANDING_LINKS_PANEL_MY_SITES")}));return BX.Landing.Backend.getInstance().getSites().then(function(n){n.forEach(function(n){this.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton(n.ID,{text:n.TITLE,onClick:this.onSiteClick.bind(this,n.ID,false),child:true}))},this)}.bind(this))},showCreatePageButton:function(){this.appendSidebarButton(new BX.Landing.UI.Button.SidebarButton("feedback_button",{className:"landing-ui-button-sidebar-feedback",text:BX.Landing.Loc.getMessage("LANDING_BLOCK__DETAIL_PAGE_PANEL_ADD_PAGE_BUTTON"),onClick:function(){var n=BX.Landing.Main.getInstance().options;var e=n.params.sef_url.site_show;var t=n.site_id;var i=e.replace("#site_show#",t)+"#createPage";window.open(i,"_blank")}}))},buildSidebar:function(){return Promise.all([this.showSourcesButtons(),this.showSitesButtons().then(function(){this.showCreatePageButton()}.bind(this))])},show:function(n){BX.Landing.UI.Panel.Content.prototype.show.call(this);this.clear();this.showLoader();this.buildSidebar();var e=this.sidebarButtons.find(function(e){return e.id===n.source});if(e){e.layout.click()}return new Promise(function(n){this.promiseResolve=n}.bind(this))}}})();
//# sourceMappingURL=detail_page_panel.map.js